package com.ruoyi.slope.inspection.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.inspection.domain.SlopeInspectionFencent;
import com.ruoyi.slope.inspection.service.ISlopeInspectionFencentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 边坡支护结构巡检Controller
 * 
 * @author ruoyi
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/slope/fencent")
public class SlopeInspectionFencentController extends BaseController
{
    @Autowired
    private ISlopeDataFileService slopeDataFileService;
    @Autowired
    private ISlopeInspectionFencentService slopeInspectionFencentService;

    /**
     * 查询边坡支护结构巡检列表
     */
    @PreAuthorize("@ss.hasPermi('slope:fencent:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeInspectionFencent slopeInspectionFencent)
    {
        startPage();
        List<SlopeInspectionFencent> list = slopeInspectionFencentService.selectSlopeInspectionFencentList(slopeInspectionFencent);
        return getDataTable(list);
    }

    /**
     * 导出边坡支护结构巡检列表
     */
    @PreAuthorize("@ss.hasPermi('slope:fencent:export')")
    @Log(title = "边坡支护结构巡检", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeInspectionFencent slopeInspectionFencent)
    {
        List<SlopeInspectionFencent> list = slopeInspectionFencentService.selectSlopeInspectionFencentList(slopeInspectionFencent);
        ExcelUtil<SlopeInspectionFencent> util = new ExcelUtil<SlopeInspectionFencent>(SlopeInspectionFencent.class);
        String path = util.exportExcel(response, list, "边坡支护结构巡检数据");
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取边坡支护结构巡检详细信息
     */
    @PreAuthorize("@ss.hasPermi('slope:fencent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeInspectionFencentService.selectSlopeInspectionFencentById(id));
    }

    /**
     * 新增边坡支护结构巡检
     */
    @PreAuthorize("@ss.hasPermi('slope:fencent:add')")
    @Log(title = "边坡支护结构巡检", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeInspectionFencent slopeInspectionFencent)
    {
        return toAjax(slopeInspectionFencentService.insertSlopeInspectionFencent(slopeInspectionFencent));
    }

    /**
     * 修改边坡支护结构巡检
     */
    @PreAuthorize("@ss.hasPermi('slope:fencent:edit')")
    @Log(title = "边坡支护结构巡检", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeInspectionFencent slopeInspectionFencent)
    {
        return toAjax(slopeInspectionFencentService.updateSlopeInspectionFencent(slopeInspectionFencent));
    }

    /**
     * 删除边坡支护结构巡检
     */
    @PreAuthorize("@ss.hasPermi('slope:fencent:remove')")
    @Log(title = "边坡支护结构巡检", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeInspectionFencentService.deleteSlopeInspectionFencentByIds(ids));
    }
}
